home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / k3baudiotrack.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-05-27  |  5.0 KB  |  215 lines

  1. /* 
  2.  *
  3.  * $Id: k3baudiotrack.h 620139 2007-01-05 11:59:05Z trueg $
  4.  * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
  5.  *
  6.  * This file is part of the K3b project.
  7.  * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
  8.  *
  9.  * This program is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2 of the License, or
  12.  * (at your option) any later version.
  13.  * See the file "COPYING" for the exact licensing terms.
  14.  */
  15.  
  16.  
  17. #ifndef K3BAUDIOTRACK_H
  18. #define K3BAUDIOTRACK_H
  19.  
  20. #include <qstring.h>
  21. #include <qfileinfo.h>
  22. #include <qfile.h>
  23. #include <qptrlist.h>
  24.  
  25. #include <kio/global.h>
  26.  
  27. #include <k3bmsf.h>
  28.  
  29. #include <k3bcdtext.h>
  30. #include <k3btrack.h>
  31. #include "k3b_export.h"
  32.  
  33. class K3bAudioDecoder;
  34. class K3bAudioDataSource;
  35. class K3bAudioDoc;
  36.  
  37.  
  38. /**
  39.  * @author Sebastian Trueg
  40.  */
  41. class LIBK3B_EXPORT K3bAudioTrack
  42. {
  43.   friend class K3bAudioDataSource;
  44.   friend class K3bAudioDoc;
  45.  
  46.  public:
  47.   K3bAudioTrack();
  48.   K3bAudioTrack( K3bAudioDoc* parent );
  49.   ~K3bAudioTrack();
  50.  
  51.   K3bAudioDoc* doc() const { return m_parent; }
  52.  
  53.   K3bDevice::Track toCdTrack() const;
  54.  
  55.   /** 
  56.    * @return length of track in frames
  57.    */
  58.   K3b::Msf length() const;
  59.   KIO::filesize_t size() const;
  60.  
  61.   const QString& artist() const { return m_cdText.performer(); }
  62.   const QString& performer() const { return m_cdText.performer(); }
  63.   const QString& title() const { return m_cdText.title(); }
  64.   const QString& arranger() const { return m_cdText.arranger(); }
  65.   const QString& songwriter() const { return m_cdText.songwriter(); }
  66.   const QString& composer() const { return m_cdText.composer(); }
  67.   const QString& isrc() const { return m_cdText.isrc(); }
  68.   const QString& cdTextMessage() const { return m_cdText.message(); }
  69.   const K3bDevice::TrackCdText& cdText() const { return m_cdText; }
  70.     
  71.   bool copyProtection() const { return m_copy; }
  72.   bool preEmp() const { return m_preEmp; }
  73.     
  74.   /**
  75.    * @obsolete use setPerformer
  76.    **/
  77.   void setArtist( const QString& a );
  78.   void setPerformer( const QString& a );
  79.   void setTitle( const QString& t );
  80.   void setArranger( const QString& t );
  81.   void setSongwriter( const QString& t );
  82.   void setComposer( const QString& t );
  83.   void setIsrc( const QString& t );
  84.   void setCdTextMessage( const QString& t );
  85.  
  86.   void setCdText( const K3bDevice::TrackCdText& cdtext );
  87.  
  88.   void setPreEmp( bool b ) { m_preEmp = b; emitChanged(); }
  89.   void setCopyProtection( bool b ) { m_copy = b; emitChanged(); }
  90.  
  91.   K3b::Msf index0() const;
  92.   /**
  93.    * The length of the postgap, ie. the number of blocks with index0.
  94.    * This is always 0 for the last track.
  95.    */
  96.   K3b::Msf postGap() const;
  97.   void setIndex0( const K3b::Msf& );
  98.  
  99.   /**
  100.    * \return The track number starting at 1.
  101.    */
  102.   unsigned int trackNumber() const;
  103.  
  104.   /**
  105.    * Remove this track from the list and return it.
  106.    */
  107.   K3bAudioTrack* take();
  108.  
  109.   /**
  110.    * Move this track after @p track.
  111.    * If @p track is null this track will be merged into the beginning
  112.    * of the docs list.
  113.    */
  114.   void moveAfter( K3bAudioTrack* track );
  115.  
  116.   /**
  117.    * Move this track ahead of @p track.
  118.    * If @p track is null this track will be appended to the end
  119.    * of the docs list.
  120.    */
  121.   void moveAhead( K3bAudioTrack* track );
  122.  
  123.   /**
  124.    * Merge @p trackToMerge into this one.
  125.    */
  126.   void merge( K3bAudioTrack* trackToMerge, K3bAudioDataSource* sourceAfter = 0 );
  127.  
  128.   K3bAudioTrack* prev() const { return m_prev; }
  129.   K3bAudioTrack* next() const { return m_next; }
  130.  
  131.   /**
  132.    * Use with care.
  133.    */
  134.   void setFirstSource( K3bAudioDataSource* source );
  135.   K3bAudioDataSource* firstSource() const { return m_firstSource; }
  136.   K3bAudioDataSource* lastSource() const;
  137.   int numberSources() const;
  138.  
  139.   /**
  140.    * Append source to the end of the sources list.
  141.    */
  142.   void addSource( K3bAudioDataSource* source );
  143.  
  144.   bool seek( const K3b::Msf& );
  145.  
  146.   /**
  147.    * Read data from the track.
  148.    *
  149.    * @return number of read bytes
  150.    */
  151.   int read( char* data, unsigned int max );
  152.  
  153.   /**
  154.    * called by K3bAudioDataSource because of the lack of signals
  155.    */
  156.   void sourceChanged( K3bAudioDataSource* );
  157.  
  158.   /**
  159.    * Create a copy of this track containing copies of all the sources
  160.    * but not being part of some list.
  161.    */
  162.   K3bAudioTrack* copy() const;
  163.  
  164.   /**
  165.    * Split the track at position pos and return the splitted track
  166.    * on success.
  167.    * The new track will be moved after this track.
  168.    *
  169.    * \param pos The position at which to split. \a pos will be the 
  170.    * first frame in the new track.
  171.    */
  172.   K3bAudioTrack* split( const K3b::Msf& pos );
  173.  
  174.   /**
  175.    * Is this track in a list
  176.    */
  177.   bool inList() const;
  178.  
  179.  private:    
  180.   /**
  181.    * Tells the doc that the track has changed
  182.    */
  183.   void emitChanged();
  184.  
  185.   void debug();
  186.  
  187.   K3bAudioDoc* m_parent;
  188.  
  189.   /** copy protection */
  190.   bool m_copy;
  191.   bool m_preEmp;
  192.  
  193.   K3b::Msf m_index0Offset;
  194.  
  195.   K3bDevice::TrackCdText m_cdText;
  196.  
  197.   // list
  198.   K3bAudioTrack* m_prev;
  199.   K3bAudioTrack* m_next;
  200.  
  201.   K3bAudioDataSource* m_firstSource;
  202.  
  203.  
  204.   K3bAudioDataSource* m_currentSource;
  205.   long long m_alreadyReadBytes;
  206.  
  207.   bool m_currentlyDeleting;
  208.  
  209.   class Private;
  210.   Private* d;
  211. };
  212.  
  213.  
  214. #endif
  215.